

#ifndef _OV5640_XCLK_
#define _OV5640_XCLK_

#include <stm32h7xx_hal.h>

#define OV5640XCLK TIM1
#define OV5640XCLK_FREQ (24 * 1000 * 1000)
#define OV5640XCLK_CLK_ENABLE() __HAL_RCC_TIM1_CLK_ENABLE()
#define OV5640XCLK_CLK_DISABLE() __HAL_RCC_TIM1_CLK_DISABLE()

/* Definition for OV5640XCLK Channel Pins  PE11 TIM1-CH2  */
#define OV5640XCLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE();
#define OV5640XCLK_GPIO_PORT_CHANNEL1 GPIOE
#define OV5640XCLK_GPIO_PORT_CHANNEL2 GPIOE
#define OV5640XCLK_GPIO_PORT_CHANNEL3 GPIOE
#define OV5640XCLK_GPIO_PORT_CHANNEL4 GPIOE

#define OV5640XCLK_GPIO_PIN_CHANNEL1 GPIO_PIN_9
#define OV5640XCLK_GPIO_PIN_CHANNEL2 GPIO_PIN_11
#define OV5640XCLK_GPIO_PIN_CHANNEL3 GPIO_PIN_13
#define OV5640XCLK_GPIO_PIN_CHANNEL4 GPIO_PIN_14
#define OV5640XCLK_GPIO_AF_CHANNEL1 GPIO_AF1_TIM1
#define OV5640XCLK_GPIO_AF_CHANNEL2 GPIO_AF1_TIM1
#define OV5640XCLK_GPIO_AF_CHANNEL3 GPIO_AF1_TIM1
#define OV5640XCLK_GPIO_AF_CHANNEL4 GPIO_AF1_TIM1

int ov5640_xclk_init();

#endif